package org.jingouzhui.domain.strategy.model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.jingouzhui.types.common.Delimiter;

/**
 * @description: 策略实体
 * @author: jingouzhui
 * @date: 2025/4/24 23:21
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StrategyEntity {

    /**
     * 抽奖策略ID
     */
    private Long strategyId;
    /**
     * 抽奖策略描述
     */
    private String strategyDesc;
    /**
     * 规则模型，rule配置的模型同步到此表，便于使用
     */
    private String ruleModels;

    public  String[] ruleModels(){
        if (StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(Delimiter.COMMA);
    }

    public String getRuleWeight(){
        String[]ruleModels = this.ruleModels();
        if(ruleModels == null) return  null;
        for (String ruleModel : ruleModels) {
            if ("rule_weight".equals(ruleModel)) return ruleModel;
        }
        return  null;
    }
}
